package com.example.hf_v1.controller;


import com.example.hf_v1.config.Result;
import com.example.hf_v1.entity.Recharge;

import com.example.hf_v1.service.IRechargeService;

import jakarta.annotation.Resource;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;

import org.springframework.web.bind.annotation.RestController;

import java.util.List;

import static net.sf.jsqlparser.util.validation.metadata.NamedObject.user;

/**
 * <p>
 * 充值表
 前端控制器
 * </p>
 *
 * @author 浪花骑士
 * @since 2024-08-07
 */
@RestController
@RequestMapping("/recharge")
public class RechargeController {

    @Resource
    private IRechargeService iRechargeService;


    //查询所有充值信息
    @RequestMapping("/getAllRecharge")
    public Result getAllRecharge() {
        return Result.success(iRechargeService.selectAllRecharge());
    }

    //根据id查询单个充值信息
    @RequestMapping("/getRechargeById")
    public Result getRechargeById(Integer id) {
        return Result.success(iRechargeService.selectAllRechargeById(id));
    }

    //增添充值信息

    @RequestMapping("/addRecharge")
    public Result addRecharge(@RequestBody Recharge recharge) {
        return Result.success(iRechargeService.saveAndUpdate(recharge));
    }

    //根据id删除充值信息
    @RequestMapping("/deleteRecharge")
    public Result deleteRecharge(Integer id) {
        return Result.success(iRechargeService.removeById(id));
    }

    //根据ids批量删除充值信息
    @RequestMapping("/deleteBatchRecharge")
    public Result deleteBatchRecharge(@RequestBody List<Integer> ids) {
        return Result.success(iRechargeService.removeByIds(ids));
    }

    //根据充值日期查询充值信息
    @RequestMapping("/selectByTime")
    public Result selectByTime(String time){
        return Result.success(iRechargeService.selectAllRechargeByTime(time));
    }

    //根据id查询use_id



}
